package com.five.taotao.guide_mine;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;

import com.five.taotao.Adapter.VPFregmentAdapter;
import com.five.taotao.R;
import com.five.taotao.guide.GuideActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class OrdersActivity extends AppCompatActivity {

    @BindView(R.id.back)
    ImageView back;
    @BindView(R.id.home)
    ImageView home;
    @BindView(R.id.tab)
    TabLayout tab;
    @BindView(R.id.vp)
    ViewPager vp;
    private List<Fragment> mData;
    private List<String> list;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_orders);
        ButterKnife.bind(this);
        initData();
        VPFregmentAdapter adapter = new VPFregmentAdapter(getSupportFragmentManager(), mData, list);
        vp.setAdapter(adapter);
        tab.setupWithViewPager(vp);//两者实现联动
    }

    /**
     * 初始化数据
     */
    private void initData() {
        mData = new ArrayList<>();
        mData.add(new AllOrderFragment());//全部
        mData.add(new PayOrderFragment());//待付款
        mData.add(new PutOrderFragment());//代发货
        mData.add(new SendOrderFragment());//待收货
        mData.add(new CommitOrderFragment());//待评价

        list = new ArrayList<>();
        list.add("全部");
        list.add("待付款");
        list.add("待发货");
        list.add("待收货");
        list.add("待评价");

    }

    @OnClick({R.id.back, R.id.home})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
            case R.id.home:
                Intent intent=new Intent(this, GuideActivity.class);
                startActivity(intent);

                overridePendingTransition(R.anim.right_in, R.anim.right_out);//移除动画
                finish();
                break;

        }
    }
}
